# Maintainer: Alexander Epaneshnikov <alex19ep@archlinux.org>
# Contributor: Antonis Geralis <capoiosct@gmail.com>

pkgname=libglkterm
pkgver=1.0.4
pkgrel=2
pkgdesc="An interface standard for interactive fiction."
arch=('loong64' 'x86_64')
url="http://eblong.com/zarf/glk/"
license=('MIT')
depends=('ncurses')
provides=('glkterm' 'glktermw')
source=(${pkgname}-${pkgver}.tar.gz::"https://github.com/erkyrath/glkterm/archive/refs/tags/glkterm-${pkgver}-widechar.tar.gz"
        "https://raw.githubusercontent.com/erkyrath/glkterm/master/LICENSE"
        "${pkgname}.patch")
sha512sums=('96f1ad2391fd377664e47c9bd21a987adee71ae1f2702c187b5e8479b1cc74057e32809ac18c0a47e9315d593519dffc4e5568b4358c1b57d2d01b53842e0656'
            '6fcf9d2dcd966f54cbf45fc0b3ab3bf2be61e78ca008f69e75ba0b500595154f9cdbe902aaa7a68806a98b92994778e29a2880c06561f1e56fb08b3b88a76554'
            '50b797002de0f7acbc9fdcaa464129dd6ab7e8e357c2d22cef45d6819f0ee539cb69e3c32463a60a77000d3ec815d6b33f2d390276e6d414944a9153e65c96e6')
b2sums=('a0b3307382ee71c34594d20d94d22b21a22021f736adf17cd7057a97ae84ded804ea43cf6ebb9232623660f285232c20d6ee9201b5aa8206bc1e7ad2681ea7d9'
        '45e955c87da65080f5cb1ed0d7ba33a281fd9e5e0067b73139b25f8d2bb0c279d5dea0212ac1a3641e031c6d38e5f1820dc2787dde41de870588802193896000'
        'c3bb4720c1cb20d69f6ff87ac95e2d765ba8329fb770de6f66df89dc0254d60709b8c9fe0276ee097043b8362f508176d0f88e923f196760ac87de6594ba21e8')

prepare() {
	cd glkterm-glkterm-${pkgver}-widechar/
	patch -Np1 -i ../${pkgname}.patch
}

build() {
	cd glkterm-glkterm-${pkgver}-widechar/
	make
}

package() {
	cd glkterm-glkterm-${pkgver}-widechar/
	# headers
	for _header in glk.h gi_*.h glkstart.h Make.glkterm; do
		install -vDm644 "${_header}" "${pkgdir}/usr/include/${_header}"
	done
	# library
	install -vDm755 libglkterm.so.${pkgver} -t "${pkgdir}/usr/lib/"
	ln -vsf /usr/lib/libglkterm.so.${pkgver} "${pkgdir}/usr/lib/libglkterm.so.1"
	ln -vsf /usr/lib/libglkterm.so.${pkgver} "${pkgdir}/usr/lib/libglkterm.so"
	# license
	install -vDm644 ../LICENSE -t "${pkgdir}/usr/share/licenses/${pkgname}"
}
